package com.sx.gongzhong.pest;

import android.content.Context;

import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.model.UserInfoBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.utils.BaseUtil;
import com.sx.gongzhong.view.LoginView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2018/1/8.
 */

public class LoginPest {
    private LoginView loginView;
    public LoginPest(LoginView loginView) {
        this.loginView = loginView;
    }

    public void login(Context context,String loginName, String password) {
        Map<String,Object> map = new HashMap<>();
        map.put("loginName",loginName);
        map.put("password",password);
        map.put("appVersion", BaseUtil.getAppVersionName(context));
        new ApiManager().login(map, new BaseCallBack<ReplyUserBean.BaseResult<UserInfoBean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<UserInfoBean> response) {
                loginView.loginSuccess(response.data);
            }
            @Override
            public void onFailures(String message) {
                loginView.showError(message);
            }
        });
    }
}
